<!DOCTYPE html><html lang="zh-CN" data-theme="light"><head><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"><title>RabbitMQ Management HTTP API的简单封装 | 西瓜蓬蓬的静谧庭院</title><meta name="keywords" content="RabbitMQ,Management,HTTP,API,java"><meta name="author" content="xiguapengpeng"><meta name="copyright" content="xiguapengpeng"><meta name="format-detection" content="telephone=no"><meta name="theme-color" content="#ffffff"><meta name="description" content="RabbitMQ Management HTTP API的简单封装[TOC] 官方相关官方文档：https:&#x2F;&#x2F;rawcdn.githack.com&#x2F;rabbitmq&#x2F;rabbitmq-server&#x2F;v3.10.0&#x2F;deps&#x2F;rabbitmq_management&#x2F;priv&#x2F;www&#x2F;api&#x2F;index.html 支持版本：rabbitmq-v3.10.0 介绍翻译：所有URI将仅服务于applic">
<meta property="og:type" content="article">
<meta property="og:title" content="RabbitMQ Management HTTP API的简单封装">
<meta property="og:url" content="https://xiguapengpeng.gitee.io/posts/785834c2/index.html">
<meta property="og:site_name" content="西瓜蓬蓬的静谧庭院">
<meta property="og:description" content="RabbitMQ Management HTTP API的简单封装[TOC] 官方相关官方文档：https:&#x2F;&#x2F;rawcdn.githack.com&#x2F;rabbitmq&#x2F;rabbitmq-server&#x2F;v3.10.0&#x2F;deps&#x2F;rabbitmq_management&#x2F;priv&#x2F;www&#x2F;api&#x2F;index.html 支持版本：rabbitmq-v3.10.0 介绍翻译：所有URI将仅服务于applic">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="http://xiguapengpeng.gitee.io/imgtu/blog/post_cover_20220512154924.png">
<meta property="article:published_time" content="2022-05-12T07:51:06.711Z">
<meta property="article:modified_time" content="2022-05-12T07:51:40.048Z">
<meta property="article:author" content="xiguapengpeng">
<meta property="article:tag" content="java">
<meta property="article:tag" content="RabbitMQ">
<meta property="article:tag" content="Management">
<meta property="article:tag" content="HTTP">
<meta property="article:tag" content="API">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="http://xiguapengpeng.gitee.io/imgtu/blog/post_cover_20220512154924.png"><link rel="shortcut icon" href="/img/favicon.png"><link rel="canonical" href="https://xiguapengpeng.gitee.io/posts/785834c2/"><link rel="preconnect" href="//cdn.jsdelivr.net"/><link rel="preconnect" href="//hm.baidu.com"/><link rel="preconnect" href="//busuanzi.ibruce.info"/><meta name="google-site-verification" content="CMfiiaCCwQ90-u9hmlL-7VUq-v_zt9rhyg1Ke1A7ia4"/><meta name="baidu-site-verification" content="code-Wsugu6NsqF"/><link rel="stylesheet" href="/css/index.css"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free/css/all.min.css" media="print" onload="this.media='all'"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fancyapps/ui/dist/fancybox.css" media="print" onload="this.media='all'"><script>var _hmt = _hmt || [];
(function() {
  var hm = document.createElement("script");
  hm.src = "https://hm.baidu.com/hm.js?0b83b38ff142c9faea5f5987d7c6f3f0";
  var s = document.getElementsByTagName("script")[0]; 
  s.parentNode.insertBefore(hm, s);
})();
</script><script>const GLOBAL_CONFIG = { 
  root: '/',
  algolia: undefined,
  localSearch: undefined,
  translate: {"defaultEncoding":2,"translateDelay":0,"msgToTraditionalChinese":"繁","msgToSimplifiedChinese":"简"},
  noticeOutdate: undefined,
  highlight: {"plugin":"highlighjs","highlightCopy":true,"highlightLang":true,"highlightHeightLimit":false},
  copy: {
    success: '复制成功',
    error: '复制错误',
    noSupport: '浏览器不支持'
  },
  relativeDate: {
    homepage: false,
    post: false
  },
  runtime: '天',
  date_suffix: {
    just: '刚刚',
    min: '分钟前',
    hour: '小时前',
    day: '天前',
    month: '个月前'
  },
  copyright: undefined,
  lightbox: 'fancybox',
  Snackbar: undefined,
  source: {
    justifiedGallery: {
      js: 'https://cdn.jsdelivr.net/npm/flickr-justified-gallery@2/dist/fjGallery.min.js',
      css: 'https://cdn.jsdelivr.net/npm/flickr-justified-gallery@2/dist/fjGallery.min.css'
    }
  },
  isPhotoFigcaption: true,
  islazyload: false,
  isAnchor: false
}</script><script id="config-diff">var GLOBAL_CONFIG_SITE = {
  title: 'RabbitMQ Management HTTP API的简单封装',
  isPost: true,
  isHome: false,
  isHighlightShrink: false,
  isToc: true,
  postUpdate: '2022-05-12 15:51:40'
}</script><noscript><style type="text/css">
  #nav {
    opacity: 1
  }
  .justified-gallery img {
    opacity: 1
  }

  #recent-posts time,
  #post-meta time {
    display: inline !important
  }
</style></noscript><script>(win=>{
    win.saveToLocal = {
      set: function setWithExpiry(key, value, ttl) {
        if (ttl === 0) return
        const now = new Date()
        const expiryDay = ttl * 86400000
        const item = {
          value: value,
          expiry: now.getTime() + expiryDay,
        }
        localStorage.setItem(key, JSON.stringify(item))
      },

      get: function getWithExpiry(key) {
        const itemStr = localStorage.getItem(key)

        if (!itemStr) {
          return undefined
        }
        const item = JSON.parse(itemStr)
        const now = new Date()

        if (now.getTime() > item.expiry) {
          localStorage.removeItem(key)
          return undefined
        }
        return item.value
      }
    }
  
    win.getScript = url => new Promise((resolve, reject) => {
      const script = document.createElement('script')
      script.src = url
      script.async = true
      script.onerror = reject
      script.onload = script.onreadystatechange = function() {
        const loadState = this.readyState
        if (loadState && loadState !== 'loaded' && loadState !== 'complete') return
        script.onload = script.onreadystatechange = null
        resolve()
      }
      document.head.appendChild(script)
    })
  
      win.activateDarkMode = function () {
        document.documentElement.setAttribute('data-theme', 'dark')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', '#0d0d0d')
        }
      }
      win.activateLightMode = function () {
        document.documentElement.setAttribute('data-theme', 'light')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', '#ffffff')
        }
      }
      const t = saveToLocal.get('theme')
    
          if (t === 'dark') activateDarkMode()
          else if (t === 'light') activateLightMode()
        
      const asideStatus = saveToLocal.get('aside-status')
      if (asideStatus !== undefined) {
        if (asideStatus === 'hide') {
          document.documentElement.classList.add('hide-aside')
        } else {
          document.documentElement.classList.remove('hide-aside')
        }
      }
    
    const detectApple = () => {
      if(/iPad|iPhone|iPod|Macintosh/.test(navigator.userAgent)){
        document.documentElement.classList.add('apple')
      }
    }
    detectApple()
    })(window)</script><meta name="generator" content="Hexo 6.0.0"></head><body><div id="loading-box"><div class="loading-left-bg"></div><div class="loading-right-bg"></div><div class="spinner-box"><div class="configure-border-1"><div class="configure-core"></div></div><div class="configure-border-2"><div class="configure-core"></div></div><div class="loading-word">加载中...</div></div></div><div id="sidebar"><div id="menu-mask"></div><div id="sidebar-menus"><div class="avatar-img is-center"><img src="https://gitee.com/xiguapengpeng/imgtu/raw/master/blog/avatar.jpg" onerror="onerror=null;src='/img/friend_404.gif'" alt="avatar"/></div><div class="site-data is-center"><div class="data-item"><a href="/archives/"><div class="headline">文章</div><div class="length-num">34</div></a></div><div class="data-item"><a href="/tags/"><div class="headline">标签</div><div class="length-num">122</div></a></div><div class="data-item"><a href="/categories/"><div class="headline">分类</div><div class="length-num">7</div></a></div></div><hr/><div class="menus_items"><div class="menus_item"><a class="site-page" href="/"><i class="fa-fw fas fa-home"></i><span> 首页</span></a></div><div class="menus_item"><a class="site-page group" href="javascript:void(0);"><i class="fa-fw fas fa-compass"></i><span> 导航</span><i class="fas fa-chevron-down"></i></a><ul class="menus_item_child"><li><a class="site-page child" href="/archives/"><i class="fa-fw fas fa-archive"></i><span> 归档</span></a></li><li><a class="site-page child" href="/tags/"><i class="fa-fw fas fa-tags"></i><span> 标签</span></a></li><li><a class="site-page child" href="/categories/"><i class="fa-fw fas fa-folder-open"></i><span> 分类</span></a></li></ul></div><div class="menus_item"><a class="site-page group" href="javascript:void(0);"><i class="fa-fw fas fa-list"></i><span> 豆瓣</span><i class="fas fa-chevron-down"></i></a><ul class="menus_item_child"><li><a class="site-page child" href="/movies/"><i class="fa-fw fas fa-video"></i><span> 电影</span></a></li><li><a class="site-page child" href="/game/"><i class="fa-fw fas fa-gamepad"></i><span> 游戏</span></a></li></ul></div><div class="menus_item"><a class="site-page" href="/link/"><i class="fa-fw fas fa-link"></i><span> 链接</span></a></div><div class="menus_item"><a class="site-page" href="/about/"><i class="fa-fw fas fa-heart"></i><span> 关于</span></a></div></div></div></div><div class="post" id="body-wrap"><header class="post-bg" id="page-header" style="background-image: url('http://xiguapengpeng.gitee.io/imgtu/blog/post_cover_20220512154924.png')"><nav id="nav"><span id="blog_name"><a id="site-name" href="/">西瓜蓬蓬的静谧庭院</a></span><div id="menus"><div class="menus_items"><div class="menus_item"><a class="site-page" href="/"><i class="fa-fw fas fa-home"></i><span> 首页</span></a></div><div class="menus_item"><a class="site-page group" href="javascript:void(0);"><i class="fa-fw fas fa-compass"></i><span> 导航</span><i class="fas fa-chevron-down"></i></a><ul class="menus_item_child"><li><a class="site-page child" href="/archives/"><i class="fa-fw fas fa-archive"></i><span> 归档</span></a></li><li><a class="site-page child" href="/tags/"><i class="fa-fw fas fa-tags"></i><span> 标签</span></a></li><li><a class="site-page child" href="/categories/"><i class="fa-fw fas fa-folder-open"></i><span> 分类</span></a></li></ul></div><div class="menus_item"><a class="site-page group" href="javascript:void(0);"><i class="fa-fw fas fa-list"></i><span> 豆瓣</span><i class="fas fa-chevron-down"></i></a><ul class="menus_item_child"><li><a class="site-page child" href="/movies/"><i class="fa-fw fas fa-video"></i><span> 电影</span></a></li><li><a class="site-page child" href="/game/"><i class="fa-fw fas fa-gamepad"></i><span> 游戏</span></a></li></ul></div><div class="menus_item"><a class="site-page" href="/link/"><i class="fa-fw fas fa-link"></i><span> 链接</span></a></div><div class="menus_item"><a class="site-page" href="/about/"><i class="fa-fw fas fa-heart"></i><span> 关于</span></a></div></div><div id="toggle-menu"><a class="site-page"><i class="fas fa-bars fa-fw"></i></a></div></div></nav><div id="post-info"><h1 class="post-title">RabbitMQ Management HTTP API的简单封装</h1><div id="post-meta"><div class="meta-firstline"><span class="post-meta-date"><i class="far fa-calendar-alt fa-fw post-meta-icon"></i><span class="post-meta-label">发表于</span><time class="post-meta-date-created" datetime="2022-05-12T07:51:06.711Z" title="发表于 2022-05-12 15:51:06">2022-05-12</time><span class="post-meta-separator">|</span><i class="fas fa-history fa-fw post-meta-icon"></i><span class="post-meta-label">更新于</span><time class="post-meta-date-updated" datetime="2022-05-12T07:51:40.048Z" title="更新于 2022-05-12 15:51:40">2022-05-12</time></span><span class="post-meta-categories"><span class="post-meta-separator">|</span><i class="fas fa-inbox fa-fw post-meta-icon"></i><a class="post-meta-categories" href="/categories/backend/">backend</a></span></div><div class="meta-secondline"><span class="post-meta-separator">|</span><span class="post-meta-wordcount"><i class="far fa-file-word fa-fw post-meta-icon"></i><span class="post-meta-label">字数总计:</span><span class="word-count">1.2k</span><span class="post-meta-separator">|</span><i class="far fa-clock fa-fw post-meta-icon"></i><span class="post-meta-label">阅读时长:</span><span>5分钟</span></span><span class="post-meta-separator">|</span><span class="post-meta-pv-cv" id="" data-flag-title="RabbitMQ Management HTTP API的简单封装"><i class="far fa-eye fa-fw post-meta-icon"></i><span class="post-meta-label">阅读量:</span><span id="busuanzi_value_page_pv"></span></span></div></div></div></header><main class="layout" id="content-inner"><div id="post"><article class="post-content" id="article-container"><h1 id="RabbitMQ-Management-HTTP-API的简单封装"><a href="#RabbitMQ-Management-HTTP-API的简单封装" class="headerlink" title="RabbitMQ Management HTTP API的简单封装"></a>RabbitMQ Management HTTP API的简单封装</h1><p>[TOC]</p>
<h2 id="官方相关"><a href="#官方相关" class="headerlink" title="官方相关"></a>官方相关</h2><p><strong>官方文档</strong>：<a target="_blank" rel="noopener" href="https://rawcdn.githack.com/rabbitmq/rabbitmq-server/v3.10.0/deps/rabbitmq_management/priv/www/api/index.html">https://rawcdn.githack.com/rabbitmq/rabbitmq-server/v3.10.0/deps/rabbitmq_management/priv/www/api/index.html</a></p>
<p><strong>支持版本</strong>：rabbitmq-v3.10.0</p>
<p><strong>介绍翻译</strong>：所有URI将仅服务于<code>application/json</code>类型的资源，并且将需要<code>HTTP Basic Auth</code>认证。许多URI要求虚拟主机的名称作为路径的一部分，因为名称只能唯一地标识虚拟主机中的对象。由于默认虚拟主机名为”&#x2F;“，因此需要将其编码为”%2F”。传参的JSON对象必须具有某些必选参数，可选参数是可以被忽略的。缺少必选参数将导致请求错误。 </p>
<p><strong>部分文档截图</strong>：</p>
<p><img src="http://xiguapengpeng.gitee.io/imgtu/blog/post_img_20220511234230.png" alt="部分文档截图"></p>
<h2 id="代码展示"><a href="#代码展示" class="headerlink" title="代码展示"></a>代码展示</h2><p>基于<code>Spring</code>框架以及<code>Hutool</code>，<code>Fastjson</code>等工具依赖</p>
<p>配置文件<code>bootstrap.yml</code>，仅供参考</p>
<figure class="highlight yaml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line"><span class="attr">rms:</span></span><br><span class="line">  <span class="attr">username:</span> <span class="string">admin</span></span><br><span class="line">  <span class="attr">password:</span> <span class="string">admin</span></span><br><span class="line">  <span class="attr">managementUrl:</span> <span class="string">http:///192.168.200.250:15672</span></span><br></pre></td></tr></table></figure>

<p>配置类<code>RmsConfig.java</code></p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">import</span> org.springframework.boot.context.properties.ConfigurationProperties;</span><br><span class="line"><span class="keyword">import</span> org.springframework.context.annotation.Configuration;</span><br><span class="line"><span class="keyword">import</span> lombok.Data;</span><br><span class="line"></span><br><span class="line"><span class="comment">/**</span></span><br><span class="line"><span class="comment"> * <span class="doctag">@ClassName</span>：RmsConfig</span></span><br><span class="line"><span class="comment"> * <span class="doctag">@Description</span>：配置类</span></span><br><span class="line"><span class="comment"> * <span class="doctag">@Author</span>：Administrator</span></span><br><span class="line"><span class="comment"> * <span class="doctag">@Date</span>：2022年5月11日下午23:17:03</span></span><br><span class="line"><span class="comment"> */</span></span><br><span class="line"><span class="meta">@Data</span></span><br><span class="line"><span class="meta">@Configuration</span></span><br><span class="line"><span class="meta">@ConfigurationProperties(prefix = &quot;rms&quot;, ignoreInvalidFields = true)</span></span><br><span class="line"><span class="keyword">public</span> <span class="keyword">class</span> <span class="title class_">RmsConfig</span> &#123;</span><br><span class="line"></span><br><span class="line">	<span class="comment">/** 管理地址 */</span> </span><br><span class="line">	<span class="keyword">private</span> String managementUrl;</span><br><span class="line">	<span class="comment">/** 连接用户名 */</span> </span><br><span class="line">    <span class="keyword">private</span> String username;</span><br><span class="line">    <span class="comment">/** 连接密码 */</span> </span><br><span class="line">    <span class="keyword">private</span> String password;</span><br><span class="line">    </span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<p>RabbitMQ管理API工具类<code>RabbitmqHttpApi.java</code>，这里拿<strong>创建用户</strong>和<strong>用户授权</strong>做例子，其他接口可以举一反三实现</p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br><span class="line">80</span><br><span class="line">81</span><br><span class="line">82</span><br><span class="line">83</span><br><span class="line">84</span><br><span class="line">85</span><br><span class="line">86</span><br><span class="line">87</span><br><span class="line">88</span><br><span class="line">89</span><br><span class="line">90</span><br><span class="line">91</span><br><span class="line">92</span><br><span class="line">93</span><br><span class="line">94</span><br><span class="line">95</span><br><span class="line">96</span><br><span class="line">97</span><br><span class="line">98</span><br><span class="line">99</span><br><span class="line">100</span><br><span class="line">101</span><br><span class="line">102</span><br><span class="line">103</span><br><span class="line">104</span><br><span class="line">105</span><br><span class="line">106</span><br><span class="line">107</span><br><span class="line">108</span><br><span class="line">109</span><br><span class="line">110</span><br><span class="line">111</span><br><span class="line">112</span><br><span class="line">113</span><br><span class="line">114</span><br><span class="line">115</span><br><span class="line">116</span><br><span class="line">117</span><br><span class="line">118</span><br><span class="line">119</span><br><span class="line">120</span><br><span class="line">121</span><br><span class="line">122</span><br><span class="line">123</span><br><span class="line">124</span><br><span class="line">125</span><br><span class="line">126</span><br><span class="line">127</span><br><span class="line">128</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">import</span> org.springframework.beans.factory.annotation.Autowired;</span><br><span class="line"><span class="keyword">import</span> org.springframework.context.annotation.DependsOn;</span><br><span class="line"><span class="keyword">import</span> org.springframework.stereotype.Component;</span><br><span class="line"><span class="keyword">import</span> com.alibaba.fastjson.JSONPath;</span><br><span class="line"><span class="keyword">import</span> cn.hutool.core.convert.Convert;</span><br><span class="line"><span class="keyword">import</span> cn.hutool.core.util.ObjectUtil;</span><br><span class="line"><span class="keyword">import</span> cn.hutool.core.util.StrUtil;</span><br><span class="line"><span class="keyword">import</span> cn.hutool.http.HttpRequest;</span><br><span class="line"><span class="keyword">import</span> cn.hutool.http.HttpResponse;</span><br><span class="line"><span class="keyword">import</span> cn.hutool.http.HttpStatus;</span><br><span class="line"></span><br><span class="line"><span class="comment">/**</span></span><br><span class="line"><span class="comment"> * <span class="doctag">@ClassName</span>：RabbitmqHttpApi</span></span><br><span class="line"><span class="comment"> * <span class="doctag">@Description</span>：RabbitMQ管理API工具类</span></span><br><span class="line"><span class="comment"> * <span class="doctag">@Author</span>：Administrator</span></span><br><span class="line"><span class="comment"> * <span class="doctag">@Date</span>：2022年5月11日下午23:23:33</span></span><br><span class="line"><span class="comment"> */</span></span><br><span class="line"><span class="meta">@DependsOn(&quot;rmsConfig&quot;)</span></span><br><span class="line"><span class="meta">@Component</span></span><br><span class="line"><span class="keyword">public</span> <span class="keyword">class</span> <span class="title class_">RabbitmqHttpApi</span> &#123;</span><br><span class="line"></span><br><span class="line">	<span class="keyword">private</span> <span class="keyword">static</span> String managementUrl;</span><br><span class="line">	<span class="keyword">private</span> <span class="keyword">static</span> String adminUsername;</span><br><span class="line">	<span class="keyword">private</span> <span class="keyword">static</span> String adminPassword;</span><br><span class="line"></span><br><span class="line">	<span class="meta">@Autowired</span></span><br><span class="line">	<span class="keyword">public</span> <span class="keyword">void</span> <span class="title function_">setMqttConfig</span><span class="params">(RmsConfig rmsConfig)</span> &#123;</span><br><span class="line">		RabbitmqHttpApi.managementUrl = rmsConfig.getManagementUrl();</span><br><span class="line">		RabbitmqHttpApi.adminUsername = rmsConfig.getUsername();</span><br><span class="line">		RabbitmqHttpApi.adminPassword = rmsConfig.getPassword();</span><br><span class="line">	&#125;</span><br><span class="line"></span><br><span class="line">	<span class="comment">/**</span></span><br><span class="line"><span class="comment">	 * <span class="doctag">@ClassName</span>：Tags</span></span><br><span class="line"><span class="comment">	 * <span class="doctag">@Description</span>：rabbitmq角色tag</span></span><br><span class="line"><span class="comment">	 * <span class="doctag">@Author</span>：Administrator</span></span><br><span class="line"><span class="comment">	 * <span class="doctag">@Date</span>：2022年5月11日下午23:25:04</span></span><br><span class="line"><span class="comment">	 */</span></span><br><span class="line">	<span class="keyword">public</span> <span class="keyword">enum</span> <span class="title class_">Tags</span> &#123;</span><br><span class="line">		<span class="comment">/** 超级管理员，可登陆管理控制台，可查看所有的信息，并且可以对用户，策略(policy)进行操作 */</span></span><br><span class="line">		ADMINISTRATOR(<span class="string">&quot;administrator&quot;</span>),</span><br><span class="line">		<span class="comment">/** 监控者，可登陆管理控制台，同时可以查看rabbitmq节点的相关信息(进程数，内存使用情况，磁盘使用情况等) */</span></span><br><span class="line">		MONITORING(<span class="string">&quot;monitoring&quot;</span>),</span><br><span class="line">		<span class="comment">/** 策略制定者，可登陆管理控制台，同时可以对policy进行管理 */</span></span><br><span class="line">		POLICYMAKER(<span class="string">&quot;policymaker&quot;</span>),</span><br><span class="line">		<span class="comment">/** 普通管理者，仅可登陆管理控制台，无法看到节点信息，也无法对策略进行管理 */</span></span><br><span class="line">		MANAGEMENT(<span class="string">&quot;management&quot;</span>),</span><br><span class="line">		<span class="comment">/** 模拟者，无法登录管理控制台 */</span></span><br><span class="line">		IMPERSONATOR(<span class="string">&quot;impersonator&quot;</span>),</span><br><span class="line">		<span class="comment">/** 其他，无法登陆管理控制台，通常就是普通的生产者和消费者 */</span></span><br><span class="line">		NONE(<span class="string">&quot;&quot;</span>);</span><br><span class="line">		<span class="keyword">private</span> <span class="keyword">final</span> String text;</span><br><span class="line">		<span class="keyword">private</span> <span class="title function_">Tags</span><span class="params">(String text)</span> &#123;</span><br><span class="line">			<span class="built_in">this</span>.text = text;</span><br><span class="line">		&#125;</span><br><span class="line">	&#125;</span><br><span class="line"></span><br><span class="line">	<span class="comment">/**</span></span><br><span class="line"><span class="comment">	 * 创建普通用户</span></span><br><span class="line"><span class="comment">	 * <span class="doctag">@param</span> username</span></span><br><span class="line"><span class="comment">	 * <span class="doctag">@param</span> password</span></span><br><span class="line"><span class="comment">	 */</span></span><br><span class="line">	<span class="keyword">public</span> <span class="keyword">static</span> <span class="type">boolean</span> <span class="title function_">createCommonUser</span><span class="params">(String username, String password)</span> <span class="keyword">throws</span> Exception &#123;</span><br><span class="line">		<span class="keyword">return</span> createUser(username, password, Tags.NONE);</span><br><span class="line">	&#125;</span><br><span class="line"></span><br><span class="line">	<span class="comment">/**</span></span><br><span class="line"><span class="comment">	 * 创建超级用户</span></span><br><span class="line"><span class="comment">	 * <span class="doctag">@param</span> username</span></span><br><span class="line"><span class="comment">	 * <span class="doctag">@param</span> password</span></span><br><span class="line"><span class="comment">	 */</span></span><br><span class="line">	<span class="keyword">public</span> <span class="keyword">static</span> <span class="type">boolean</span> <span class="title function_">createAdminUser</span><span class="params">(String username, String password)</span> <span class="keyword">throws</span> Exception &#123;</span><br><span class="line">		<span class="keyword">return</span> createUser(username, password, Tags.ADMINISTRATOR);</span><br><span class="line">	&#125;</span><br><span class="line"></span><br><span class="line">	<span class="comment">/**</span></span><br><span class="line"><span class="comment">	 * 创建用户</span></span><br><span class="line"><span class="comment">	 * 参考文档`/api/users/&#123;name&#125;`接口</span></span><br><span class="line"><span class="comment">	 * <span class="doctag">@param</span> username</span></span><br><span class="line"><span class="comment">	 * <span class="doctag">@param</span> password</span></span><br><span class="line"><span class="comment">	 */</span></span><br><span class="line">	<span class="keyword">public</span> <span class="keyword">static</span> <span class="type">boolean</span> <span class="title function_">createUser</span><span class="params">(String username, String password, Tags tags)</span> <span class="keyword">throws</span> Exception &#123;</span><br><span class="line">		<span class="type">String</span> <span class="variable">param</span> <span class="operator">=</span> String.format(<span class="string">&quot;&#123;\&quot;password\&quot;:\&quot;%s\&quot;,\&quot;tags\&quot;:\&quot;%s\&quot;&#125;&quot;</span>, password, tags.text);</span><br><span class="line">		<span class="type">String</span> <span class="variable">url</span> <span class="operator">=</span> String.format(<span class="string">&quot;%s/api/users/%s&quot;</span>, managementUrl, username);</span><br><span class="line">		<span class="type">HttpResponse</span> <span class="variable">response</span> <span class="operator">=</span> HttpRequest.put(url).basicAuth(adminUsername, adminPassword).body(param).execute();</span><br><span class="line">		<span class="keyword">return</span> response.getStatus() == HttpStatus.HTTP_CREATED || response.getStatus() == HttpStatus.HTTP_NO_CONTENT;</span><br><span class="line">	&#125;</span><br><span class="line"></span><br><span class="line">	<span class="comment">/**</span></span><br><span class="line"><span class="comment">	 * 设置所有权限</span></span><br><span class="line"><span class="comment">	 * <span class="doctag">@param</span> username</span></span><br><span class="line"><span class="comment">	 */</span></span><br><span class="line">	<span class="keyword">public</span> <span class="keyword">static</span> <span class="type">boolean</span> <span class="title function_">setAllPermissions</span><span class="params">(String username)</span> <span class="keyword">throws</span> Exception &#123;</span><br><span class="line">		<span class="keyword">return</span> setPermissions(username, <span class="string">&quot;/&quot;</span>, <span class="string">&quot;.*&quot;</span>, <span class="string">&quot;.*&quot;</span>, <span class="string">&quot;.*&quot;</span>);</span><br><span class="line">	&#125;</span><br><span class="line"></span><br><span class="line">	<span class="comment">/**</span></span><br><span class="line"><span class="comment">	 * 设置权限</span></span><br><span class="line"><span class="comment">	 * 参考文档`/api/permissions/&#123;vhost&#125;/&#123;name&#125;`接口</span></span><br><span class="line"><span class="comment">	 * <span class="doctag">@param</span> username</span></span><br><span class="line"><span class="comment">	 * <span class="doctag">@param</span> virtualHost</span></span><br><span class="line"><span class="comment">	 * <span class="doctag">@param</span> configureRegexp</span></span><br><span class="line"><span class="comment">	 * <span class="doctag">@param</span> writeRegexp</span></span><br><span class="line"><span class="comment">	 * <span class="doctag">@param</span> readRegexp</span></span><br><span class="line"><span class="comment">	 */</span></span><br><span class="line">	<span class="keyword">public</span> <span class="keyword">static</span> <span class="type">boolean</span> <span class="title function_">setPermissions</span><span class="params">(String username, String virtualHost, String configureRegexp,</span></span><br><span class="line"><span class="params">			String writeRegexp, String readRegexp)</span> <span class="keyword">throws</span> Exception &#123;</span><br><span class="line">		<span class="type">String</span> <span class="variable">param</span> <span class="operator">=</span> String.format(<span class="string">&quot;&#123;\&quot;configure\&quot;:\&quot;.*\&quot;,\&quot;write\&quot;:\&quot;.*\&quot;,\&quot;read\&quot;:\&quot;.*\&quot;&#125;&quot;</span>, configureRegexp,</span><br><span class="line">				writeRegexp, readRegexp);</span><br><span class="line">		virtualHost = StrUtil.equals(<span class="string">&quot;/&quot;</span>, virtualHost) ? <span class="string">&quot;%2F&quot;</span> : virtualHost;</span><br><span class="line">		<span class="type">String</span> <span class="variable">url</span> <span class="operator">=</span> managementUrl + <span class="string">&quot;/api/permissions/&quot;</span> + virtualHost + <span class="string">&quot;/&quot;</span> + username;</span><br><span class="line">		<span class="type">HttpResponse</span> <span class="variable">response</span> <span class="operator">=</span> HttpRequest.put(url).basicAuth(adminUsername, adminPassword).body(param).execute();</span><br><span class="line">		<span class="keyword">return</span> response.getStatus() == HttpStatus.HTTP_CREATED || response.getStatus() == HttpStatus.HTTP_NO_CONTENT;</span><br><span class="line">	&#125;</span><br><span class="line">    </span><br><span class="line">    <span class="comment">/**</span></span><br><span class="line"><span class="comment">	 * 获取集群节点socket使用数量</span></span><br><span class="line"><span class="comment">	 * 参考文档`/api/nodes`接口</span></span><br><span class="line"><span class="comment">	 * <span class="doctag">@return</span> array</span></span><br><span class="line"><span class="comment">	 */</span></span><br><span class="line">	<span class="keyword">public</span> <span class="keyword">static</span> Integer[] getUsedSockets() <span class="keyword">throws</span> Exception &#123;</span><br><span class="line">		<span class="type">String</span> <span class="variable">url</span> <span class="operator">=</span> managementUrl + <span class="string">&quot;/api/nodes&quot;</span>;</span><br><span class="line">		<span class="type">HttpResponse</span> <span class="variable">response</span> <span class="operator">=</span> HttpRequest.get(url).basicAuth(adminUsername, adminPassword).execute();</span><br><span class="line">		<span class="type">Object</span> <span class="variable">object</span> <span class="operator">=</span> JSONPath.read(response.body(), <span class="string">&quot;$[&#x27;sockets_used&#x27;]&quot;</span>);</span><br><span class="line">		<span class="keyword">return</span> ObjectUtil.isNotNull(object) ? Convert.toIntArray(object) : <span class="keyword">new</span> <span class="title class_">Integer</span>[] &#123;&#125;;</span><br><span class="line">	&#125;</span><br><span class="line"></span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<p>在业务中调用，仅供参考</p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">/**</span></span><br><span class="line"><span class="comment"> * 某某业务实现</span></span><br><span class="line"><span class="comment"> * <span class="doctag">@param</span> username</span></span><br><span class="line"><span class="comment"> * <span class="doctag">@param</span> password</span></span><br><span class="line"><span class="comment"> */</span></span><br><span class="line"><span class="keyword">public</span> <span class="keyword">void</span> <span class="title function_">doBiz</span><span class="params">(String username, String password)</span> &#123;</span><br><span class="line">    <span class="keyword">if</span> (createClientUser(username, password)) &#123;</span><br><span class="line">        logger.info(<span class="string">&quot;创建rabbitmq用户【&#123;&#125;】成功&quot;</span>, username);</span><br><span class="line">    &#125;</span><br><span class="line">    <span class="type">Integer</span> <span class="variable">nodeIndex</span> <span class="operator">=</span> dispatchNode();</span><br><span class="line">    <span class="keyword">if</span> (!ObjectUtil.isNull(nodeIndex)) &#123;</span><br><span class="line">        logger.info(<span class="string">&quot;节点【&#123;&#125;】连接数最少，进行调度&quot;</span>, nodeIndex + <span class="number">1</span>);</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="comment">/**</span></span><br><span class="line"><span class="comment"> * 创建连接客户端用户</span></span><br><span class="line"><span class="comment"> * <span class="doctag">@param</span> username</span></span><br><span class="line"><span class="comment"> * <span class="doctag">@param</span> password</span></span><br><span class="line"><span class="comment"> */</span></span><br><span class="line"><span class="keyword">public</span> <span class="type">boolean</span> <span class="title function_">createClientUser</span><span class="params">(String username, String password)</span> &#123;</span><br><span class="line">    <span class="keyword">try</span> &#123;</span><br><span class="line">        <span class="keyword">return</span> RabbitmqHttpApi.createCommonUser(username, password) &amp;&amp; RabbitmqHttpApi.setAllPermissions(username);</span><br><span class="line">    &#125; <span class="keyword">catch</span> (Exception e) &#123;</span><br><span class="line">        logger.error(<span class="string">&quot;创建rabbitmq用户【&#123;&#125;】异常：&#123;&#125;&quot;</span>, username, e.getMessage());</span><br><span class="line">        <span class="keyword">return</span> <span class="literal">false</span>;</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="comment">/** 调度mqtt节点 */</span></span><br><span class="line"><span class="keyword">public</span> Integer <span class="title function_">dispatchNode</span><span class="params">()</span> &#123;</span><br><span class="line">    <span class="keyword">try</span> &#123;</span><br><span class="line">        Integer[] useds = RabbitmqHttpApi.getUsedSockets();</span><br><span class="line">        <span class="keyword">if</span> (useds.length == <span class="number">0</span>) &#123;</span><br><span class="line">            <span class="keyword">throw</span> <span class="keyword">new</span> <span class="title class_">Exception</span>(<span class="string">&quot;接口未获取到集群各节点socket使用数量&quot;</span>);</span><br><span class="line">        &#125;</span><br><span class="line">        <span class="keyword">return</span> ArrayUtil.indexOf(useds, NumberUtil.min(useds));</span><br><span class="line">    &#125; <span class="keyword">catch</span> (Exception e) &#123;</span><br><span class="line">        logger.error(<span class="string">&quot;调度mqtt节点异常：&#123;&#125;&quot;</span>, e.getMessage());</span><br><span class="line">    &#125;</span><br><span class="line">    <span class="keyword">return</span> <span class="literal">null</span>;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

</article><div class="post-copyright"><div class="post-copyright__author"><span class="post-copyright-meta">文章作者: </span><span class="post-copyright-info"><a href="mailto:undefined">xiguapengpeng</a></span></div><div class="post-copyright__type"><span class="post-copyright-meta">文章链接: </span><span class="post-copyright-info"><a href="https://xiguapengpeng.gitee.io/posts/785834c2/">https://xiguapengpeng.gitee.io/posts/785834c2/</a></span></div><div class="post-copyright__notice"><span class="post-copyright-meta">版权声明: </span><span class="post-copyright-info">本博客所有文章除特别声明外，均采用 <a href="https://creativecommons.org/licenses/by-nc-sa/4.0/" target="_blank">CC BY-NC-SA 4.0</a> 许可协议。转载请注明来自 <a href="https://xiguapengpeng.gitee.io" target="_blank">西瓜蓬蓬的静谧庭院</a>！</span></div></div><div class="tag_share"><div class="post-meta__tag-list"><a class="post-meta__tags" href="/tags/java/">java</a><a class="post-meta__tags" href="/tags/RabbitMQ/">RabbitMQ</a><a class="post-meta__tags" href="/tags/Management/">Management</a><a class="post-meta__tags" href="/tags/HTTP/">HTTP</a><a class="post-meta__tags" href="/tags/API/">API</a></div><div class="post_share"><div class="social-share" data-image="http://xiguapengpeng.gitee.io/imgtu/blog/post_cover_20220512154924.png" data-sites="facebook,twitter,wechat,weibo,qq"></div><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/social-share.js/dist/css/share.min.css" media="print" onload="this.media='all'"><script src="https://cdn.jsdelivr.net/npm/social-share.js/dist/js/social-share.min.js" defer></script></div></div><div class="post-reward"><div class="reward-button"><i class="fas fa-qrcode"></i> 打赏</div><div class="reward-main"><ul class="reward-all"><li class="reward-item"><a href="https://gitee.com/xiguapengpeng/imgtu/raw/master/blog/wx_reward.jpg" target="_blank"><img class="post-qr-code-img" src="https://gitee.com/xiguapengpeng/imgtu/raw/master/blog/wx_reward.jpg" alt="微信"/></a><div class="post-qr-code-desc">微信</div></li></ul></div></div><nav class="pagination-post" id="pagination"><div class="prev-post pull-left"><a href="/posts/d589ee65/"><img class="prev-cover" src="http://xiguapengpeng.gitee.io/imgtu/blog/post_cover_20220625153017.png" onerror="onerror=null;src='/img/404.jpg'" alt="cover of previous post"><div class="pagination-info"><div class="label">上一篇</div><div class="prev_info">固态硬盘M.2与SATA3.0的区别</div></div></a></div><div class="next-post pull-right"><a href="/posts/5eba0d43/"><img class="next-cover" src="http://xiguapengpeng.gitee.io/imgtu/blog/post_cover_20220412213713.png" onerror="onerror=null;src='/img/404.jpg'" alt="cover of next post"><div class="pagination-info"><div class="label">下一篇</div><div class="next_info">docker-compose部署MinIO分布式集群</div></div></a></div></nav><div class="relatedPosts"><div class="headline"><i class="fas fa-thumbs-up fa-fw"></i><span>相关推荐</span></div><div class="relatedPosts-list"><div><a href="/posts/b3dd0b9e/" title="CentOS7安装jdk环境"><img class="cover" src="http://xiguapengpeng.gitee.io/imgtu/blog/post_cover_1644828629.png" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2022-02-18</div><div class="title">CentOS7安装jdk环境</div></div></a></div><div><a href="/posts/fdc8614/" title="Java8到Java17之间的主要特性描述"><img class="cover" src="http://xiguapengpeng.gitee.io/imgtu/blog/post_cover_20230130095755.png" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2023-01-30</div><div class="title">Java8到Java17之间的主要特性描述</div></div></a></div><div><a href="/posts/bd6c95d5/" title="Windows10安装java环境"><img class="cover" src="http://xiguapengpeng.gitee.io/imgtu/blog/post_cover_20230131095714.png" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2023-01-31</div><div class="title">Windows10安装java环境</div></div></a></div><div><a href="/posts/ce8ba00a/" title="docker-compose部署RabbitMQ分布式集群"><img class="cover" src="http://xiguapengpeng.gitee.io/imgtu/blog/post_img_20220412213937.png" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2022-04-12</div><div class="title">docker-compose部署RabbitMQ分布式集群</div></div></a></div></div></div></div><div class="aside-content" id="aside-content"><div class="card-widget card-info"><div class="is-center"><div class="avatar-img"><img src="https://gitee.com/xiguapengpeng/imgtu/raw/master/blog/avatar.jpg" onerror="this.onerror=null;this.src='/img/friend_404.gif'" alt="avatar"/></div><div class="author-info__name">xiguapengpeng</div><div class="author-info__description">分享知识、勤做笔记</div></div><div class="card-info-data is-center"><div class="card-info-data-item"><a href="/archives/"><div class="headline">文章</div><div class="length-num">34</div></a></div><div class="card-info-data-item"><a href="/tags/"><div class="headline">标签</div><div class="length-num">122</div></a></div><div class="card-info-data-item"><a href="/categories/"><div class="headline">分类</div><div class="length-num">7</div></a></div></div><a id="card-info-btn" target="_blank" rel="noopener" href="https://github.com/xiguapengpeng"><i class="fab fa-heart"></i><span>个人仓库</span></a></div><div class="card-widget card-announcement"><div class="item-headline"><i class="fas fa-bullhorn card-announcement-animation"></i><span>公告</span></div><div class="announcement_content">若时光逝却，就珍存过往</div></div><div class="sticky_layout"><div class="card-widget" id="card-toc"><div class="item-headline"><i class="fas fa-stream"></i><span>目录</span><span class="toc-percentage"></span></div><div class="toc-content"><ol class="toc"><li class="toc-item toc-level-1"><a class="toc-link" href="#RabbitMQ-Management-HTTP-API%E7%9A%84%E7%AE%80%E5%8D%95%E5%B0%81%E8%A3%85"><span class="toc-number">1.</span> <span class="toc-text">RabbitMQ Management HTTP API的简单封装</span></a><ol class="toc-child"><li class="toc-item toc-level-2"><a class="toc-link" href="#%E5%AE%98%E6%96%B9%E7%9B%B8%E5%85%B3"><span class="toc-number">1.1.</span> <span class="toc-text">官方相关</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E4%BB%A3%E7%A0%81%E5%B1%95%E7%A4%BA"><span class="toc-number">1.2.</span> <span class="toc-text">代码展示</span></a></li></ol></li></ol></div></div><div class="card-widget card-recent-post"><div class="item-headline"><i class="fas fa-history"></i><span>最新文章</span></div><div class="aside-list"><div class="aside-list-item"><a class="thumbnail" href="/posts/bd6c95d5/" title="Windows10安装java环境"><img src="http://xiguapengpeng.gitee.io/imgtu/blog/post_cover_20230131095714.png" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="Windows10安装java环境"/></a><div class="content"><a class="title" href="/posts/bd6c95d5/" title="Windows10安装java环境">Windows10安装java环境</a><time datetime="2023-01-31T01:59:34.432Z" title="发表于 2023-01-31 09:59:34">2023-01-31</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/posts/fdc8614/" title="Java8到Java17之间的主要特性描述"><img src="http://xiguapengpeng.gitee.io/imgtu/blog/post_cover_20230130095755.png" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="Java8到Java17之间的主要特性描述"/></a><div class="content"><a class="title" href="/posts/fdc8614/" title="Java8到Java17之间的主要特性描述">Java8到Java17之间的主要特性描述</a><time datetime="2023-01-30T01:59:04.252Z" title="发表于 2023-01-30 09:59:04">2023-01-30</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/posts/9542a1f7/" title="CentOS7安装OpenSSL环境"><img src="http://xiguapengpeng.gitee.io/imgtu/blog/post_cover_20230114172144.png" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="CentOS7安装OpenSSL环境"/></a><div class="content"><a class="title" href="/posts/9542a1f7/" title="CentOS7安装OpenSSL环境">CentOS7安装OpenSSL环境</a><time datetime="2023-01-14T09:34:08.209Z" title="发表于 2023-01-14 17:34:08">2023-01-14</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/posts/da432f73/" title="OpenSSL生成证书"><img src="http://xiguapengpeng.gitee.io/imgtu/blog/post_cover_20230114172959.png" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="OpenSSL生成证书"/></a><div class="content"><a class="title" href="/posts/da432f73/" title="OpenSSL生成证书">OpenSSL生成证书</a><time datetime="2023-01-14T09:33:46.203Z" title="发表于 2023-01-14 17:33:46">2023-01-14</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/posts/e0523c/" title="CentOS7安装cmake工具"><img src="http://xiguapengpeng.gitee.io/imgtu/blog/post_cover_20221217113021.png" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="CentOS7安装cmake工具"/></a><div class="content"><a class="title" href="/posts/e0523c/" title="CentOS7安装cmake工具">CentOS7安装cmake工具</a><time datetime="2022-12-17T03:39:03.528Z" title="发表于 2022-12-17 11:39:03">2022-12-17</time></div></div></div></div></div></div></main><footer id="footer" style="background-image: url('http://xiguapengpeng.gitee.io/imgtu/blog/post_cover_20220512154924.png')"><div id="footer-wrap"><div class="copyright">&copy;2022 - 2023 By xiguapengpeng</div><div class="framework-info"><span>框架 </span><a target="_blank" rel="noopener" href="https://hexo.io">Hexo</a><span class="footer-separator">|</span><span>主题 </span><a target="_blank" rel="noopener" href="https://github.com/jerryc127/hexo-theme-butterfly">Butterfly</a></div><div class="footer_custom_text">醉后不知天在水，满船清梦压星河。</div></div></footer></div><div id="rightside"><div id="rightside-config-hide"><button id="readmode" type="button" title="阅读模式"><i class="fas fa-book-open"></i></button><button id="translateLink" type="button" title="简繁转换">繁</button><button id="darkmode" type="button" title="浅色和深色模式转换"><i class="fas fa-adjust"></i></button><button id="hide-aside-btn" type="button" title="单栏和双栏切换"><i class="fas fa-arrows-alt-h"></i></button></div><div id="rightside-config-show"><button id="rightside_config" type="button" title="设置"><i class="fas fa-cog fa-spin"></i></button><button class="close" id="mobile-toc-button" type="button" title="目录"><i class="fas fa-list-ul"></i></button><button id="go-up" type="button" title="回到顶部"><i class="fas fa-arrow-up"></i></button></div></div><div><script src="/js/utils.js"></script><script src="/js/main.js"></script><script src="/js/tw_cn.js"></script><script src="https://cdn.jsdelivr.net/npm/@fancyapps/ui/dist/fancybox.umd.js"></script><script src="https://cdn.jsdelivr.net/npm/instant.page/instantpage.min.js" type="module"></script><script>var preloader = {
  endLoading: () => {
    document.body.style.overflow = 'auto';
    document.getElementById('loading-box').classList.add("loaded")
  },
  initLoading: () => {
    document.body.style.overflow = '';
    document.getElementById('loading-box').classList.remove("loaded")

  }
}
window.addEventListener('load',preloader.endLoading())</script><div class="js-pjax"></div><div class="aplayer no-destroy" data-id="60198" data-server="netease" data-type="playlist" data-fixed="true" data-autoplay="true"></div><canvas class="fireworks" mobile="false"></canvas><script src="https://cdn.jsdelivr.net/npm/butterfly-extsrc@1/dist/fireworks.min.js"></script><script defer="defer" id="fluttering_ribbon" mobile="true" src="https://cdn.jsdelivr.net/npm/butterfly-extsrc@1/dist/canvas-fluttering-ribbon.min.js"></script><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/aplayer/dist/APlayer.min.css" media="print" onload="this.media='all'"><script src="https://cdn.jsdelivr.net/npm/aplayer/dist/APlayer.min.js"></script><script src="https://cdn.jsdelivr.net/gh/metowolf/MetingJS@1.2/dist/Meting.min.js"></script><script src="https://cdn.jsdelivr.net/npm/pjax/pjax.min.js"></script><script>let pjaxSelectors = ["title","#config-diff","#body-wrap","#rightside-config-hide","#rightside-config-show",".js-pjax"]

var pjax = new Pjax({
  elements: 'a:not([target="_blank"])',
  selectors: pjaxSelectors,
  cacheBust: false,
  analytics: false,
  scrollRestoration: false
})

document.addEventListener('pjax:send', function () {

  // removeEventListener scroll 
  window.tocScrollFn && window.removeEventListener('scroll', window.tocScrollFn)
  window.scrollCollect && window.removeEventListener('scroll', scrollCollect)

  typeof preloader === 'object' && preloader.initLoading()
  document.getElementById('rightside').style.cssText = "opacity: ''; transform: ''"
  
  if (window.aplayers) {
    for (let i = 0; i < window.aplayers.length; i++) {
      if (!window.aplayers[i].options.fixed) {
        window.aplayers[i].destroy()
      }
    }
  }

  typeof typed === 'object' && typed.destroy()

  //reset readmode
  const $bodyClassList = document.body.classList
  $bodyClassList.contains('read-mode') && $bodyClassList.remove('read-mode')

})

document.addEventListener('pjax:complete', function () {
  window.refreshFn()

  document.querySelectorAll('script[data-pjax]').forEach(item => {
    const newScript = document.createElement('script')
    const content = item.text || item.textContent || item.innerHTML || ""
    Array.from(item.attributes).forEach(attr => newScript.setAttribute(attr.name, attr.value))
    newScript.appendChild(document.createTextNode(content))
    item.parentNode.replaceChild(newScript, item)
  })

  GLOBAL_CONFIG.islazyload && window.lazyLoadInstance.update()

  typeof chatBtnFn === 'function' && chatBtnFn()
  typeof panguInit === 'function' && panguInit()

  // google analytics
  typeof gtag === 'function' && gtag('config', '', {'page_path': window.location.pathname});

  // baidu analytics
  typeof _hmt === 'object' && _hmt.push(['_trackPageview',window.location.pathname]);

  typeof loadMeting === 'function' && document.getElementsByClassName('aplayer').length && loadMeting()

  // prismjs
  typeof Prism === 'object' && Prism.highlightAll()

  typeof preloader === 'object' && preloader.endLoading()
})

document.addEventListener('pjax:error', (e) => {
  if (e.request.status === 404) {
    pjax.loadUrl('/404.html')
  }
})</script><script async data-pjax src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script></div><script src="/live2dw/lib/L2Dwidget.min.js?094cbace49a39548bed64abff5988b05"></script><script>L2Dwidget.init({"pluginRootPath":"live2dw/","pluginJsPath":"lib/","pluginModelPath":"assets/","tagMode":false,"debug":false,"model":{"jsonPath":"/live2dw/assets/hijiki.model.json"},"display":{"position":"right","width":150,"height":300},"mobile":{"show":false},"log":false});</script></body></html>